//
//  CFMarketVC.m
//  CFfuturestalent
//
//  Created by 子yu 刘 on 2018/5/3.
//  Copyright © 2018年 子yu 刘. All rights reserved.
//

#import "CFMarketVC.h"

@interface CFMarketVC ()

@property (nonatomic,assign)NSInteger segIndex;

@end

@implementation CFMarketVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatNav];
}

- (void)creatNav{
    UISegmentedControl * midControl = [[UISegmentedControl alloc]initWithItems:@[@"自选",@"行情"]];
    midControl.tintColor = [UIColor whiteColor];
    midControl.frame = CGRectMake(0, 0, 150, 28);
    NSDictionary *dic1 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],
                          NSForegroundColorAttributeName,
                          [UIFont boldSystemFontOfSize:14],
                          NSFontAttributeName,nil];
    NSDictionary *dic2 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithHexString:@"24292e"],
                          NSForegroundColorAttributeName,
                          [UIFont boldSystemFontOfSize:14],
                          NSFontAttributeName,nil];
    [midControl setTitleTextAttributes:dic1 forState:UIControlStateNormal];
    [midControl setTitleTextAttributes:dic2 forState:UIControlStateSelected];
    [midControl addTarget:self action:@selector(didClicksegmentedControlAction:)forControlEvents:UIControlEventValueChanged];
    midControl.selectedSegmentIndex = 0;
    self.navigationItem.titleView = midControl;
}

- (void)didClicksegmentedControlAction:(UISegmentedControl *)Seg{
    _segIndex = Seg.selectedSegmentIndex;
    switch (_segIndex) {
        case 0:
             [self.scrollView scrollRectToVisible:CGRectMake(0, 0, DEF_SCREEN_WIDTH(), self.scrollView.frame.size.height) animated:YES];
            break;
        case 1:
            [self.scrollView scrollRectToVisible:CGRectMake(DEF_SCREEN_WIDTH(), 0, DEF_SCREEN_WIDTH(), self.scrollView.frame.size.height) animated:YES];
            break;
        default:
            break;
    }
}
@end
